 function hide_this(el) {
     $(el).bind("click", function () {
         $(".background_hide").hide()
         $("#demo").hide()
         $("#hidval").val(0)
         $(document.body).css({"overflow-y":"scroll"});
 })
 };

//保留价格和积分的小数位数
function changeDecimal(x,y)
{
    var f_x = parseFloat(x);
    if (isNaN(f_x))
    {
        alert('function:changeTwoDecimal->parameter error');
        return false;
    }
    var f_x = Math.round(x*y)/y;

    return f_x;
}

 //隐藏购物清单
 function hide_menu(){
     $(".background_hide").hide()
     $("#demo").hide()
     $("#hidval").val(0)
     $(document.body).css({"overflow":"scroll"});
 }

 //下拉菜单
 function show_hide() {
     var  val=$("#hidval").val()
     if ($("#hidval").val() == 0) {
         $(".background_hide").show()
         $("#demo").show()
         $(document.body).css({"overflow":"hidden"});
         $("#hidval").val(1)
     } else {
         $(".background_hide").hide()
         $("#demo").hide()
         $("#hidval").val(0)
         $(document.body).css({"overflow":"scroll"});
     }
 };

 //单击收起
 function click_retract(id){

     var state = document.getElementById(id).style;
     if(state.display == "block" ||state.display == ""){
        state.display = 'none';
     } else if(state.display == "none"){
         state.display = 'block';
     }
 }
 //输入框提示不同内容
 function input_alert(html){
     var float_element = $(".c-float-popWrap")
     var hei = $(window).height()/2
     var top = $(document).scrollTop()+hei-30;
     float_element.css({"top":top+"px"})
     $(".warnMsg").html(html)
     float_element.show()
     setTimeout(function(){
         float_element.hide()
     },2000);

 }
 //购物车编辑操作
 function cartGoodsEdit(editId, goodsEditId, goodsCompleteId, deleteId) {
     var edit = document.getElementById(editId);
     var edit_goods = $("." + goodsEditId);
     var edit_complete = $("." + goodsCompleteId);
     var deleteId = $("." + deleteId);
     var width_ = 6.4 / 6;
     if (edit.innerHTML == '编辑') {
         edit_goods.show();
         edit_complete.hide();
         deleteId.css({width: width_ + "rem"});
         edit.innerHTML = '完成';
     } else if (edit.innerHTML = '完成') {
         edit_goods.hide();
         edit_complete.show();
         deleteId.css({width: "0"});
         edit.innerHTML = '编辑';
     }
 }
 //模态框取消按钮函数
 function dismiss() {
     $(".contain-no").click(function () {
         $(".contain-item").fadeOut();
         $(".contain-item1").fadeOut();
         $(".contain-item2").fadeOut();
     })
 }
 //cookie设置读取和删除
 //设置
 function setCookie(name, value, day) {
     var Days = day;
     var exp = new Date();
     exp.setTime(exp.getTime() + Days*24*60*60*1000);
     document.cookie = name + "=" + escape(value) + ";expires=" + exp.toGMTString();
 }
 //读取
 function getCookie(name) {
     var arr, reg = new RegExp("(^| )" + name + "=([^;]*)(;|$)");
     if (arr = document.cookie.match(reg)) {
         return unescape(arr[2]);
     }
     else {
         return null;
     }
 }
 //删除
 function delCookie(name) {
     var exp = new Date();
     exp.setTime(exp.getTime() - 1);
     var cval = getCookie(name);
     if (cval != null){
         document.cookie = name + "=" + cval + ";expires=" + exp.toGMTString();
     }
 }
 //下单页面样式控制
 function placeOrderEnterCss(position1,speed1,position2,speed2){
     $(".payment_show").css({transform:"translateX("+position1+"px)",WebkitTransform:"translateX("+position1+"px)",WebkitTransition: "all "+speed1+"ms ease",transition: "all "+speed1+"ms ease"})
     $(".addr_hide").css({transform:"translateX("+position2+"px)",WebkitTransform:"translateX("+position2+"px)",WebkitTransition: "all "+speed2+"ms ease",transition: "all "+speed2+"ms ease"})
 }
 //我的订单页不同入口设置不同区域active
 function order_active(act, actid) {
     var active = $(act)
     var activeid = $(actid)
     active.addClass("active")
     activeid.addClass("active")
 }